body {
  margin: 0;
  padding: 20px;
  font-family: 'Oswald', 'Segoe UI', system-ui, sans-serif;
  background: #000;
  color: #fff;
  line-height: 1.6;
}

.container {
  max-width: 800px;
  margin: 0 auto;
}

h1,
h2,
h3 {
  font-family: 'Bebas Neue', sans-serif;
  letter-spacing: 1.5px;
  text-transform: uppercase;
}

h1 {
  text-align: center;
  color: #ff3c3c;
  font-size: 4rem;
  text-shadow: 0 0 10px rgba(255, 60, 60, 0.5);
}

.character-select {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 40px 0;
  gap: 20px;
  flex-wrap: wrap;
}

.character-input {
  flex: 1;
  min-width: 250px;
  animation: fadeInUp 0.5s ease-out;
}

.character-input:nth-child(2) {
  animation-delay: 0.2s;
}

.vs {
  font-size: 2em;
  font-weight: bold;
  color: #ff3c3c;
  text-shadow: 0 0 10px rgba(255, 60, 60, 0.5);
  animation: glow 2s infinite;
  position: relative;
  animation: pulse 2s infinite;
}

input {
  width: 100%;
  padding: 10px;
  margin: 5px 0;
  border: 2px solid #333;
  background: #2a2a2a;
  color: #fff;
  border-radius: 5px;
}

input:focus {
  outline: none;
  border-color: #ff3c3c;
}

button {
  display: block;
  width: 100%;
  padding: 15px;
  background: #ff3c3c;
  color: white;
  border: none;
  border-radius: 5px;
  font-family: 'Oswald', sans-serif;
  font-size: 1.2em;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  cursor: pointer;
  transition: transform 0.2s, background 0.2s;
  position: relative;
  overflow: hidden;
}

button::after {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle, rgba(255,255,255,0.2) 0%, transparent 60%);
  opacity: 0;
  transform: scale(0.5);
  transition: transform 0.3s, opacity 0.3s;
}

button:hover {
  background: #ff5555;
  transform: scale(1.02);
}

button:hover::after {
  opacity: 1;
  transform: scale(1);
}

.battle-container {
  margin-top: 40px;
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.5s, transform 0.5s;
}

.battle-container.visible {
  opacity: 1;
  transform: translateY(0);
}

.battle-container.visible .analysis { animation-delay: 0.3s; }
.battle-container.visible .battle { animation-delay: 0.6s; }
.battle-container.visible .winner { animation-delay: 0.9s; }

.hidden {
  display: none;
}

.battle-animation {
  display: flex;
  justify-content: center;
  margin: 20px 0;
}

.battle-animation svg {
  width: 300px;
  height: 300px;
  transform-origin: center;
  animation: shake 0.5s ease-in-out;
}

.explosion {
  fill: #ff3c3c;
  opacity: 0;
}

.sword1, .sword2 {
  stroke: #fff;
  stroke-width: 4;
  stroke-linecap: round;
  fill: none;
  opacity: 0;
}

@keyframes explode {
  0% { r: 0; opacity: 0; }
  25% { r: 40; opacity: 0.8; fill: #ff3c3c; }
  50% { r: 80; opacity: 0.6; fill: #ffa500; }
  75% { r: 90; opacity: 0.4; fill: #ffff00; }
  100% { r: 100; opacity: 0; }
}

@keyframes swordClash {
  0% { opacity: 0; stroke-dashoffset: 300; transform: translate(0, 0); }
  30% { opacity: 1; stroke-dashoffset: 0; transform: translate(-10px, -10px); }
  50% { opacity: 1; stroke-dashoffset: 0; transform: translate(0, 0); }
  70% { opacity: 1; stroke-dashoffset: 0; transform: translate(10px, 10px); }
  100% { opacity: 0; stroke-dashoffset: 300; transform: translate(0, 0); }
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-5px); }
  75% { transform: translateX(5px); }
}

@keyframes glow {
  0%, 100% { filter: drop-shadow(0 0 5px rgba(255, 60, 60, 0.5)); }
  50% { filter: drop-shadow(0 0 20px rgba(255, 60, 60, 0.8)); }
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateX(-20px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes pulse {
  0% {
    transform: scale(1);
    text-shadow: 0 0 10px rgba(255, 60, 60, 0.5);
  }
  50% {
    transform: scale(1.1);
    text-shadow: 0 0 20px rgba(255, 60, 60, 0.8);
  }
  100% {
    transform: scale(1);
    text-shadow: 0 0 10px rgba(255, 60, 60, 0.5);
  }
}

.speech-controls {
  position: absolute;
  top: 20px;
  right: 20px;
  display: flex;
  gap: 10px;
  z-index: 1;
}

.speak-btn,
.stop-btn {
  width: 40px;
  height: 40px;
  padding: 8px;
  border-radius: 50%;
  background: rgba(255, 60, 60, 0.2);
  border: 2px solid #ff3c3c;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.speak-btn:hover,
.stop-btn:hover {
  background: rgba(255, 60, 60, 0.4);
  transform: scale(1.1);
}

.speak-btn svg,
.stop-btn svg {
  width: 24px;
  height: 24px;
  fill: #fff;
}

.analysis, .battle, .winner {
  position: relative;
  background: rgba(255, 60, 60, 0.1);
  padding: 20px;
  margin: 20px 0;
  border-radius: 10px;
  cursor: pointer;
  transition: transform 0.2s;
  animation: fadeInUp 0.5s ease-out;
  overflow: hidden;
}

.analysis::before, .battle::before, .winner::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.1),
    transparent
  );
  transition: 0.5s;
}

.analysis:hover, .battle:hover, .winner:hover {
  transform: scale(1.01);
}

.analysis:hover::before, .battle:hover::before, .winner:hover::before {
  left: 100%;
}

.analysis:active, .battle:active, .winner:active {
  transform: scale(0.99);
}

h3 {
  color: #ff3c3c;
  margin-top: 0;
  font-size: 1.8rem;
}

blockquote {
  border-left: 4px solid #ff3c3c;
  margin: 15px 0;
  padding: 10px 20px;
  background: rgba(255, 60, 60, 0.1);
  border-radius: 0 10px 10px 0;
  transform: translateX(0);
  transition: transform 0.3s ease;
  animation: slideIn 0.5s ease-out;
}

blockquote:hover {
  transform: translateX(10px);
}

.music-controls {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 1000;
  display: flex;
  gap: 10px;
}

.music-toggle {
  width: 40px;
  height: 40px;
  padding: 8px;
  border-radius: 50%;
  background: rgba(255, 60, 60, 0.2);
  border: 2px solid #ff3c3c;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.music-toggle:hover {
  background: rgba(255, 60, 60, 0.4);
  transform: scale(1.1);
}

.music-toggle svg {
  width: 24px;
  height: 24px;
  fill: #fff;
}

.battle-location {
  margin: 20px 0;
  animation: fadeInUp 0.5s ease-out;
  animation-delay: 0.4s;
}

.battle-location h2 {
  color: #ff3c3c;
  font-size: 1.5rem;
  margin-bottom: 10px;
  text-align: center;
}

.battle-location input {
  width: 100%;
  padding: 15px;
  margin: 5px 0;
  border: 2px solid #333;
  background: #2a2a2a;
  color: #fff;
  border-radius: 5px;
  font-size: 1.1em;
}

.battle-location input:focus {
  outline: none;
  border-color: #ff3c3c;
  box-shadow: 0 0 10px rgba(255, 60, 60, 0.3);
}

.button-group {
  display: flex;
  gap: 10px;
  margin: 20px 0;
}

.button-group button {
  flex: 1;
}

#save-btn {
  background: #b32b2b;
}

#save-btn:hover {
  background: #c83030;
}

.saved-battles-toggle {
  margin: 20px 0;
}

#view-saved-battles {
  background: #444;
  width: 100%;
}

#view-saved-battles:hover {
  background: #555;
}

.saved-battles {
  margin: 20px 0;
  padding: 20px;
  background: rgba(255, 60, 60, 0.1);
  border-radius: 10px;
  animation: fadeInUp 0.5s ease-out;
}

.saved-battles h2 {
  color: #ff3c3c;
  text-align: center;
  margin-top: 0;
}

.saved-battle-card {
  background: rgba(255, 255, 255, 0.05);
  padding: 15px;
  margin: 10px 0;
  border-radius: 5px;
  cursor: pointer;
  transition: all 0.3s ease;
  position: relative;
}

.saved-battle-card:hover {
  transform: translateX(10px);
  background: rgba(255, 255, 255, 0.1);
}

.saved-battle-title {
  font-size: 1.2em;
  color: #ff3c3c;
  margin-bottom: 5px;
}

.saved-battle-location {
  font-size: 0.9em;
  color: #888;
}

.saved-battle-date {
  position: absolute;
  top: 15px;
  right: 15px;
  font-size: 0.8em;
  color: #666;
}

.delete-battle {
  position: absolute;
  bottom: 15px;
  right: 15px;
  background: #e74c3c;
  color: white;
  border: none;
  border-radius: 3px;
  padding: 5px 10px;
  cursor: pointer;
  font-size: 0.8em;
  transition: all 0.2s ease;
}

.delete-battle:hover {
  background: #c0392b;
}

.add-characters-toggle {
  text-align: center;
  margin: 20px 0;
}

#toggle-extra-chars {
  background: linear-gradient(45deg, #444, #333);
  width: auto;
  padding: 12px 25px;
  margin: 0 auto;
  font-family: 'Oswald', sans-serif;
  text-transform: uppercase;
  font-size: 1.1em;
  border-radius: 25px;
  box-shadow: 0 4px 15px rgba(100, 100, 100, 0.3);
  transition: all 0.3s ease;
}

#toggle-extra-chars:hover {
  background: linear-gradient(45deg, #333, #444);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(100, 100, 100, 0.4);
}

#toggle-extra-chars:active {
  transform: translateY(1px);
}

.extra-characters {
  opacity: 0;
  max-height: 0;
  overflow: hidden;
  transition: all 0.3s ease;
  margin: 20px 0;
}

.extra-characters.visible {
  opacity: 1;
  max-height: 800px;
  margin: 20px 0;
}

.battles-tabs {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
  border-bottom: 2px solid rgba(255, 255, 255, 0.1);
  padding-bottom: 10px;
}

.tab {
  background: transparent;
  color: #fff;
  border: none;
  padding: 10px 20px;
  cursor: pointer;
  opacity: 0.6;
  transition: all 0.3s ease;
  border-radius: 20px;
}

.tab:hover {
  opacity: 0.8;
  background: rgba(255, 60, 60, 0.1);
}

.tab.active {
  opacity: 1;
  background: #ff3c3c;
  transform: none;
}

.battle-author {
  font-size: 0.9em;
  color: #888;
  margin-top: 5px;
}

.battle-controls {
  display: flex;
  gap: 10px;
  position: absolute;
  bottom: 15px;
  right: 15px;
}

.share-battle {
  background: #444;
  color: white;
  border: none;
  border-radius: 3px;
  padding: 5px 10px;
  cursor: pointer;
  font-size: 0.8em;
  transition: all 0.2s ease;
}

.share-battle:hover {
  background: #555;
}

.loading,
.no-battles,
.error {
  text-align: center;
  padding: 20px;
  color: #888;
}

.error {
  color: #e74c3c;
}

.battles-container {
  min-height: 100px;
}

.team-members {
  margin: 20px 0;
  animation: fadeInUp 0.5s ease-out;
}

.team-members .character-select {
  margin: 0;
}

.team-members .character-input {
  border-left: 4px solid;
  padding-left: 15px;
}

.team-members .character-input:nth-child(1) {
  border-left-color: #ff3c3c;
}

.team-members .character-input:nth-child(3) {
  border-left-color: #666;
}

@media (max-width: 600px) {
  .team-members .character-input {
    border-left: none;
    padding-left: 0;
    border-top: 4px solid;
    padding-top: 15px;
  }

  .team-members .character-input:nth-child(1) {
    border-top-color: #ff3c3c;
  }

  .team-members .character-input:nth-child(3) {
    border-top-color: #666;
  }
}

@media (max-width: 600px) {
  body {
    padding: 10px;
  }

  h1 {
    font-size: 2rem;
    margin: 15px 0;
  }

  .container {
    width: 100%;
    padding: 0;
  }

  .character-select {
    flex-direction: column;
    text-align: center;
    gap: 10px;
  }
  
  .character-input {
    min-width: auto;
    width: 100%;
  }

  .character-input h2 {
    font-size: 1.3rem;
    margin: 10px 0;
  }
  
  .vs {
    margin: 10px 0;
    font-size: 1.8em;
  }
  
  input {
    padding: 12px;
    font-size: 16px; /* Prevents iOS zoom on focus */
  }
  
  .battle-animation svg {
    width: 200px;
    height: 200px;
  }

  .speech-controls {
    top: 10px;
    right: 10px;
    gap: 5px;
  }
  
  .speak-btn,
  .stop-btn {
    width: 36px;
    height: 36px;
    padding: 6px;
  }
  
  .music-controls {
    bottom: 10px;
    right: 10px;
  }
  
  .music-toggle {
    width: 36px;
    height: 36px;
    padding: 6px;
  }
  
  .extra-characters.visible {
    max-height: 1000px; /* Increased to accommodate mobile layout */
  }
  
  .extra-characters .character-select {
    gap: 15px;
  }

  .extra-characters .vs {
    margin: 5px 0;
    font-size: 1.5em;
  }

  #toggle-extra-chars {
    width: 100%;
    padding: 12px;
    font-size: 1em;
    white-space: normal; /* Allow text to wrap */
  }
  
  .battles-tabs {
    flex-direction: row;
    gap: 5px;
    overflow-x: auto;
    padding-bottom: 5px;
    -webkit-overflow-scrolling: touch;
  }

  .tab {
    flex: 1;
    padding: 8px;
    font-size: 0.9em;
    white-space: nowrap;
  }

  .battle-controls {
    position: static;
    margin-top: 10px;
    flex-direction: row;
    justify-content: flex-end;
  }

  .saved-battle-card {
    padding: 12px;
    padding-bottom: 60px;
    margin: 8px 0;
  }

  .saved-battle-title {
    font-size: 1.1em;
    padding-right: 70px; /* Make room for date */
  }

  .saved-battle-date {
    top: 12px;
    right: 12px;
  }

  .button-group {
    flex-direction: column;
    gap: 8px;
  }

  .button-group button {
    width: 100%;
    padding: 12px;
  }

  .analysis, .battle, .winner {
    padding: 15px;
    margin: 15px 0;
  }

  blockquote {
    padding: 8px 15px;
    margin: 12px 0;
  }

  /* Improve touch targets */
  button, 
  .saved-battle-card,
  .tab {
    min-height: 44px; /* iOS minimum touch target size */
  }

  /* Prevent horizontal scrolling */
  .container {
    overflow-x: hidden;
  }

  /* Better spacing for battle content */
  #analysis-content,
  #battle-content,
  #winner-content {
    font-size: 0.95em;
    line-height: 1.5;
  }

  /* Improve readability of battle text */
  .battle-content p,
  .analysis-content p,
  .winner-content p {
    margin: 0.8em 0;
  }

  /* Make saved battles more compact on mobile */
  .battles-container {
    margin-top: 10px;
  }

  /* Adjust loading states for mobile */
  .loading,
  .no-battles,
  .error {
    padding: 15px;
    font-size: 0.9em;
  }

  /* Improved mobile-friendly form layout */
  .battle-location input {
    font-size: 16px;
    padding: 12px;
  }

  /* Better spacing for the location section */
  .battle-location h2 {
    font-size: 1.3rem;
    margin: 15px 0 10px;
  }

  /* Adjust saved battles toggle button */
  #view-saved-battles {
    padding: 12px;
    font-size: 1em;
  }

  /* Make speech controls more touch-friendly */
  .speech-controls button {
    min-width: 44px;
    min-height: 44px;
  }
}

/* Additional support for larger phones and small tablets */
@media (min-width: 601px) and (max-width: 768px) {
  .container {
    width: 90%;
    max-width: none;
  }

  .character-select {
    gap: 15px;
  }

  .character-input {
    min-width: 200px;
  }

  .button-group {
    flex-direction: row;
    gap: 10px;
  }
}

/* Support for landscape orientation */
@media (max-width: 900px) and (orientation: landscape) {
  .character-select {
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
    gap: 15px;
  }

  .character-input {
    flex: 0 1 calc(50% - 30px);
    min-width: 0;
  }

  .vs {
    flex: 0 0 100%;
    margin: 5px 0;
    font-size: 1.5em;
  }

  .battle-animation svg {
    width: 150px;
    height: 150px;
  }
}

.mode-toggle {
  margin: 20px 0;
  text-align: center;
}

.mode-toggle button {
  background: linear-gradient(45deg, #ff3c3c, #ff5555);
  width: auto;
  padding: 12px 25px;
  margin: 0 10px;
  font-family: 'Bebas Neue', sans-serif;
  letter-spacing: 1px;
  font-size: 1.1em;
  border-radius: 25px;
  box-shadow: 0 4px 15px rgba(255, 60, 60, 0.3);
  transition: all 0.3s ease;
  font-weight: 700;
  text-transform: uppercase;
}

.mode-toggle button.active {
  background: #444;
  transform: scale(1.05);
}

.team-names {
  display: flex;
  gap: 20px;
  margin: 20px 0;
  animation: fadeInUp 0.5s ease-out;
}

.team-name-input {
  flex: 1;
}

.team-name-input h3 {
  color: #ff3c3c;
  margin-bottom: 10px;
}

.team-name-input input {
  width: 100%;
  padding: 10px;
  background: #2a2a2a;
  border: 2px solid #333;
  color: #fff;
  border-radius: 5px;
}

.team-name-input.red-team input {
  border-color: #ff3c3c;
}

.team-name-input.blue-team input {
  border-color: #666;
}

.character-select.team-mode .character-input:nth-child(1),
.character-select.team-mode .character-input:nth-child(3) {
  border-left: 4px solid #ff3c3c;
  padding-left: 15px;
}

.character-select.team-mode .character-input:nth-child(4),
.character-select.team-mode .character-input:nth-child(6) {
  border-left: 4px solid #666;
  padding-left: 15px;
}

@media (max-width: 600px) {
  .mode-toggle button {
    width: 100%;
    margin: 5px 0;
    padding: 10px;
    font-size: 1em;
  }

  .team-names {
    flex-direction: column;
    gap: 10px;
  }

  .team-name-input {
    width: 100%;
  }

  .character-select.team-mode .character-input {
    border-left: none !important;
    padding-left: 0 !important;
  }

  .character-select.team-mode .character-input:nth-child(1),
  .character-select.team-mode .character-input:nth-child(3) {
    border-top: 4px solid #ff3c3c;
    padding-top: 15px;
  }

  .character-select.team-mode .character-input:nth-child(4),
  .character-select.team-mode .character-input:nth-child(6) {
    border-top: 4px solid #666;
    padding-top: 15px;
  }
}

.notice {
  text-align: center;
  color: white;
  padding: 20px;
  margin-top: 40px;
  font-style: italic;
  opacity: 0.8;
}

@media (max-width: 600px) {
  .notice {
    padding: 15px;
    margin-top: 30px;
    font-size: 0.9em;
  }
}